function initDeviceId() {
	return (
		(Math.random() * 10000000).toString(16).substr(0, 4) +
		'' +
		new Date().getTime() +
		'' +
		Math.random()
			.toString()
			.substr(2, 5)
	);
}

function getCookie(key) {
	var arr,
		reg = new RegExp('(^| )' + key + '=([^;]*)(;|$)');
	if ((arr = document.cookie.match(reg))) return unescape(arr[2]);
	else return null;
}

function getLocalStorage(key) {
	return JSON.parse(window.localStorage.getItem(key));
}
function setLocalStorage(key, data) {
	return window.localStorage.setItem(key, JSON.stringify(data));
}

export { initDeviceId, getCookie, getLocalStorage, setLocalStorage };
